const children = [
    {
        // 动漫板块界面
        path: '/anime',
        name: 'AnimeForum',
        component: () => import('@/views/anime/Anime.vue')
    },
    {
        // 发布动漫的编辑界面
        path: '/anime/post',
        name: 'PostAnime',
        component: () => import('@/views/anime/post/Post.vue')
    },
    {
        // 动漫详情页
        path: '/anime/detail',
        name: 'AnimeDEtail',
        component: () => import('@/views/anime/detail/Detail.vue')
    },
    {
        // 发布漫评的编辑界面
        path: '/anime/review',
        name: 'PostReview',
        component: () => import('@/views/anime/review/Review.vue')
    },
    {
        // 漫评详情页面
        path: '/anime/review/detail',
        name: 'ReviewDetail',
        component: () => import('@/views/anime/review/detail/Detail.vue')
    },
    {
        // 论坛板块界面
        path: '/forum',
        name: 'Forum',
        component: () => import('@/views/forum/Forum.vue')
    },
    {
        // 发布主题帖的编辑界面
        path: '/forum/subject',
        name: 'PostSubject',
        component: () => import('@/views/forum/subject/Subject.vue')
    },
    {
        // 主题帖详情页
        path: '/forum/detail',
        name: 'SubjectDetail',
        component: () => import('@/views/forum/detail/Detail.vue')
    },
    {
        // 反馈版块
        path: '/feedback',
        name: 'Feedback',
        component: () => import('@/views/feedback/Feedback.vue')
    },
    {
        // 发布反馈贴的界面
        path: '/feedback/post',
        name: 'PostFeedback',
        component: () => import('@/views/feedback/post/Post.vue')
    },
    {
        // 反馈贴详情界面
        path: '/feedback/detail',
        name: 'FeedbackDetail',
        component: () => import('@/views/feedback/detail/Detail.vue')
    },
    {
        // 审核界面
        path: '/face/examine',
        name: 'Examine',
        component: () => import('@/views/face/examine/Examine.vue')
    },
    {
        // 敏感词管理界面
        path: '/face/regulation',
        name: 'Regulation',
        component: () => import('@/views/face/regulation/Regulation.vue')
    },
    {
        // Tag管理界面
        path: '/face/tag',
        name: 'Tag',
        component: () => import('@/views/face/tag/Tag.vue')
    },
    {
        // 报表查看界面
        path: '/sys/report',
        name: 'Report',
        component: () => import('@/views/sys/report/Report.vue')
    },
    {
        // 广告管理界面
        path: '/sys/ad',
        name: 'Advertisement',
        component: () => import('@/views/sys/ad/Ad.vue')
    },
    {
        // 工作人员管理界面
        path: '/usergroup/worker',
        name: 'Worker',
        component: () => import('@/views/usergroup/worker/Worker.vue')
    },
    {
        // 普通注册用户管理界面
        path: '/usergroup/normal',
        name: 'NormalUser',
        component: () => import('@/views/usergroup/normal/Normal.vue')
    },
    {
        // 用户组管理界面
        path: '/usergroup/manage',
        name: 'UserGroupManage',
        component: () => import('@/views/usergroup/manage/Manage.vue')
    },
    {
        // 对用户进行禁言的界面
        path: '/words/mute',
        name: 'Mute',
        component: () => import('@/views/words/mute/Mute.vue')
    }

];
const routes = [

    //访问路由“/”,自动重定向到"/forum"
    {
        path: '/',
        redirect: '/forum'
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/login.vue')
    },
    {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/home.vue'),
        children
    },
    {
        path: '/register',
        name: 'Register',
        component: () => import('@/views/register.vue')
    },

    {
        path: '/404',
        name: "NotFound",
        component: () => import('@/views/404.vue')
    },

    {
        path: '/500',
        name: 'ServerError',
        component: () => import('@/views/500.vue')
    },

    {
        path: '/418',
        name: 'Teapot',
        component: () => import('@/views/418.vue')
    },

    {
        path: '/403',
        name: 'AccessForbidden',
        component: () => import('@/views/403.vue')
    },

    //test
    {
        path: '/tags',
        name: 'ViewTags',
        component: ()=>import('@/views/face/tag/Tag.vue')
    }


];

export const existsRoute = (path) => {
    for (let i = 0; i < routes.length; i++) {
        const r = routes[i];
        if (r.path == path) {
            return true;
        }
        if (r.children && r.children.length) {
            for (let k = 0; k < r.children.length; k++) {
                const sr = r.children[k];
                if (sr.path == path) {
                    return true;
                }
            }
        }
    }
    return false;
};

export default routes;